{{message-error model=key}}
<form class="{{if showAdvancedMode 'advanced-edit' 'simple-edit'}}" onsubmit={{action "createOrUpdateKey" "create"}} onchange={{action "handleChange"}}>
  <div class="field box is-fullwidth is-sideless is-marginless">
    <label class="label is-font-weight-normal" for="kv-key">Path for this secret</label>
    <div class="field has-addons">
      {{#if (not-eq key.initialParentKey '') }}
        {{! need this to prevent a shift in the layout before we transition when saving }}
        {{#if key.isCreating}}
          <p class="control is-no-flex-grow">
            <button type="button" class="button is-static has-background-grey-lighter has-text-grey has-default-border">
              {{key.initialParentKey}}
            </button>
          </p>
        {{else}}
          <p class="control is-no-flex-grow">
            <button type="button" class="button is-static">
              {{key.parentKey}}
            </button>
          </p>
        {{/if}}
      {{/if}}
      <p class="control is-expanded">
        {{input data-test-secret-path=true id="kv-key" class="input" value=key.keyWithoutParent}}
      </p>
    </div>
    {{#if key.isFolder}}
      <p class="help is-danger">
      The secret path may not end in <code>/</code>
      </p>
    {{/if}}
  </div>

  {{partial "partials/secret-edit-display"}}

  <div class="field is-grouped box is-fullwidth is-bottomless">
    <div class="control">
      <button
       type="submit"
       disabled={{buttonDisabled}}
       class="button is-primary"
       data-test-secret-save=true
       >
         Save
      </button>
    </div>
    <div class="control">
      {{#secret-link
        mode="list"
        secret=key.initialParentKey
        class="button"
      }}
        Cancel
      {{/secret-link}}
    </div>
  </div>
</form>
